@ECHO OFF

REM Revision of last commit: $Rev: 22498 $
REM Author of last commit: $Author: anurinm $
REM Date of last commit: $Date: 2013-10-22 18:45:52 +0300 (Р’С‚, 22 Р–РѕРІ 2013) $
REM $HeadURL: https://ims-svn.swissbank.com/prod/UBond/trunk/build.cmd $


SET MSBUILD=msbuild.exe
SET SCRIPT_DIR=%~dp0%
SET TARGET=%1%
SET ULTRABOND_ART_FILE=%SCRIPT_DIR%build\ultrabond.art


IF EXIST "%ULTRABOND_ART_FILE%" (
	ECHO.
	TYPE "%ULTRABOND_ART_FILE%" 
	ECHO.
)


IF "%TARGET%"=="" (
	ECHO TARGET is not defined. Using default target.
)


REM ECHO MSBUILD=%MSBUILD%
REM ECHO TARGET=%TARGET%


ECHO Checking for the environment...


REM Check for installed MSBuild
%MSBUILD% /version >nul 2>&1
SET TEST_STATUS=%ERRORLEVEL%
IF %TEST_STATUS%==0 (
	ECHO [OK] %MSBUILD% is accessible.
) ELSE (
	ECHO [ERROR] %MSBUILD% is unaccessible! Add directory that contains MSBuild.exe to the PATH variable.
	GOTO FINISH_ERROR
)


SET MSBUILD_ARGS="%SCRIPT_DIR%build\build.msbuild"
IF NOT "%TARGET%"=="" (
	SET MSBUILD_ARGS=%MSBUILD_ARGS% "/t:%TARGET%"
)


ECHO $ %MSBUILD% %MSBUILD_ARGS%
%MSBUILD% %MSBUILD_ARGS%
SET TEST_STATUS=%ERRORLEVEL%
IF NOT %TEST_STATUS%==0 (
	ECHO [ERROR] MSBuild failed!
	GOTO FINISH_ERROR
)


:FINISH_OK
EXIT /B 0


:FINISH_ERROR
EXIT /B 1